#ifndef _FLASH_H_
#define _FLASH_H_
#include "system.h"
#define CONFIG_ADRESS 0x0807F800
#define PAGE_SIZE ((u32)0x800)
typedef u32 (*pFlashProgramWord)(u32, u32 *, u32);
typedef u32 (*pFlashReadWord)(u32, u32 *, u16);
typedef u8 (*pFlashReadByte)(u32, u8 *, u16);
typedef void (*pFlashEraseAllPages)(void);
typedef u16 (*pFlashErasePage)(u32);
typedef struct
{
    /* data */
    pFlashProgramWord   PflashProgramWord;
    pFlashReadWord      PflashReadWord;
    pFlashReadByte      PflashReadByte;
    pFlashEraseAllPages PflashEraseAllPages; 
    pFlashErasePage     PflashErasePage;    
} flash_t;
flash_t *flashCreate(void);
#if ELECT
u32 flash_programword(u32 address, u32 *p_source, u32 len);
u32 flash_readword(u32 address, u32 *p_source, u16 cnt);
u8 flash_readbyte(u32 address, u32 *p_source, u16 cnt);
void flash_eraseallpages(void);
u16 flash_erasepage(u32 pageAddress);
#endif
#endif
